<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>设计模式</title>
</head>

<body>
  <h2>观察者模式</h2>
  <script>
    // 观察者模式
    window.addEventListener('load', () => console.log('load触发1'))
    window.addEventListener('load', () => console.log('load触发2'))
    window.addEventListener('load', () => console.log('load触发3'))


    export default {
      data() {
        return {
          message: '',
        }
      },
      watch: {
        message(newMes, oldMes) {
          console.log('message-change')
        }
      },
    }
  </script>
</body>

</html>